package org.eclipsedevx.appengine.usage;

import java.util.Iterator;

import com.google.appengine.api.blobstore.BlobInfo;
import com.google.appengine.api.blobstore.BlobInfoFactory;
import com.google.appengine.api.blobstore.BlobKey;

/**
 * 
 * @author dcarew
 */
public class BlobUtil {

	private BlobUtil() {
		
	}
	
	public static BlobKey getBlobNamed(String fileName) {
		BlobInfoFactory blobInfoFactory = new BlobInfoFactory();
		
		Iterator<BlobInfo> blobs = blobInfoFactory.queryBlobInfos();
		
		while (blobs.hasNext()) {
			BlobInfo info = blobs.next();
			
			if (fileName.equals(info.getFilename())) {
				return info.getBlobKey();
			}
		}
		
		return null;
	}
	
}
